package com.lwc.cfdns.pojo;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;

import java.sql.Timestamp;

/**
 * 实例基类
 *
 * @author luwc
 * @title BaseEntity
 * @description
 * @time 2023/4/25 16:39:08
 * @version: 1.0
 */
@Data
public class BaseEntity<T extends Model<?>> extends Model<T> {

    @TableField(value = "creator_id", fill = FieldFill.INSERT)
    protected Long creatorId;

    @TableField(value = "created_at", fill = FieldFill.INSERT)// 自动填充
    protected Timestamp createdAt;

    @TableField(value = "updater_id", fill = FieldFill.UPDATE)
    protected Long updaterId;

    @TableField(value = "updated_at", fill = FieldFill.UPDATE)// 自动填充
    protected Timestamp updatedAt;

    /**
     * deleted字段请在数据库中 设置为tinyInt   并且非null   默认值为0
     * 删除标志（0代表存在 1代表删除）
     */
    @TableField("deleted")
    @TableLogic //逻辑删除
    protected Integer deleted;

    // @TableLogic(value = "null", delval = "UNIX_TIMESTAMP()")
    @TableField(value = "deleted_at")
    protected Timestamp deletedAt;
}
